package com.jbm.jsm.iface;

import com.jbm.core.iface.IAcross;
import org.hibernate.annotations.*;
import org.hibernate.annotations.Cache;

import javax.persistence.*;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.List;

/**
 * Created by Administrator on 2017/9/26.
 */
@Entity
@Table(name = "geo_info", schema = "", catalog = "jsm")
@org.hibernate.annotations.Entity(dynamicUpdate=true,dynamicInsert=true)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class GeoInfoEntity extends IAcross
{
    private int giId;
    private String giCode;
    private String giName;
    private Integer prevId;
    private Integer level;
    private List<GeoInfoEntity> geoList;
    private Integer orders;
    private String type;

    public GeoInfoEntity()
    {
        super();
    }

    public GeoInfoEntity(IAcross ia)
    {
        super(ia);
    }

    public GeoInfoEntity(int giId) {
        this.giId = giId;
    }

    @Id
    @Column(name = "gi_id")
    @GeneratedValue
    public int getGiId() {
        return giId;
    }

    public void setGiId(int giId) {
        this.giId = giId;
    }

    @Basic
    @Column(name = "gi_code")
    public String getGiCode() {
        return giCode;
    }

    public void setGiCode(String giCode) {
        this.giCode = giCode;
    }

    @Basic
    @Column(name = "gi_name")
    public String getGiName() {
        return giName;
    }

    public void setGiName(String giName) {
        this.giName = giName;
    }

    @Basic
    @Column(name = "prev_id")
    public Integer getPrevId() {
        return prevId;
    }

    public void setPrevId(Integer prevId) {
        this.prevId = prevId;
    }

    @Basic
    @Column(name = "level")
    public Integer getLevel() {
        return level;
    }

    public void setLevel(Integer level) {
        this.level = level;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        GeoInfoEntity that = (GeoInfoEntity) o;

        if (giId != that.giId) return false;
        if (giCode != null ? !giCode.equals(that.giCode) : that.giCode != null) return false;
        if (giName != null ? !giName.equals(that.giName) : that.giName != null) return false;
        if (level != null ? !level.equals(that.level) : that.level != null) return false;
        if (prevId != null ? !prevId.equals(that.prevId) : that.prevId != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = giId;
        result = 31 * result + (giCode != null ? giCode.hashCode() : 0);
        result = 31 * result + (giName != null ? giName.hashCode() : 0);
        result = 31 * result + (prevId != null ? prevId.hashCode() : 0);
        result = 31 * result + (level != null ? level.hashCode() : 0);
        return result;
    }

@Transient
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
    public List<GeoInfoEntity> getGeoList() {
        return geoList;
    }

    public void setGeoList(List<GeoInfoEntity> geoList) {
        this.geoList = geoList;
    }

    @Basic
    @Column(name = "orders")
    public Integer getOrders() {
        return orders;
    }

    public void setOrders(Integer orders) {
        this.orders = orders;
    }

    @Basic
    @Column(name = "type")
    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    @Override
    public String toString() {
        return  getGiName();
    }
}
